import $api from '.';

interface shangpin {
  name: string;
  [key: string]: any;
}
// 添加商品
export const addshangbiao = function (data: shangpin) {
  return $api.post('/shangshop', data);
};
// 获取所有商品列表
export const getshangbiaoList = function (data: { $limit: number; $skip: number }) {
  console.log('data', data);
  data.$limit = data.$limit || 20;
  data.$skip = data.$skip || 0;
  return $api.get('/shangshop', {
    params: data,
  });
};
// 获取指定字段信息
export const getstate = function (data: { name: any; }) {
};
// 修改
export const updateGoods = function (id: number, data: any) {
  return $api.patch(`/shangshop/${id}`, data);
};
// 修改状态
export const updatestate = function (id: number, data: any) {
  return $api.patch(`/shangshop/${id}`, data);
};

// 删除商品
export const delshangbiao = function (id: number) {
  return $api.delete(`/shangshop/${id}`);
};
// 查询
export const getchaxun = (data: { $limit: number; $skip: number;
  name: any; state: any; }) => {
  // chaname: any 根据名称来查询
  data.$limit = data.$limit || 20;
  data.$skip = data.$skip || 0;
  return $api.get('/shangshop', {
    params: data,
  });
};
export default {};
